import matplotlib.pyplot as plt
import numpy as np
from matplotlib import cm
plt.style.use('_mpl-gallery')
# Make data
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)
# Plot the surface
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
ax.plot_surface(X, Y, Z, vmin=Z.min() * 2, cmap=cm.Blues)
ax.set(xticklabels=[],
yticklabels=[],
zticklabels=[])
plt.show()
This code produces a 3D plot of the sine function on a grid, resulting in a blue, Wavy surface.
import seaborn as sns
sns.set_theme(style="ticks", palette="pastel")
# Load the example tips dataset
tips = sns.load_dataset("tips")
# Draw a nested boxplot to show bills by day and time
sns.boxplot(x="day", y="total_bill",
hue="smoker", palette=["m", "g"],
data=tips)
sns.despine(offset=10, trim=True)
This describes the distribution of total bills across days, differentiated by smoker status, with a pastel color palette and tick styling, using the "tips" dataset.
import plotly
plotly.offline.init_notebook_mode()
import plotly.express as px
df = px.data.gapminder()
fig = px.scatter(df.query("year==2007"), x="gdpPercap", y="lifeExp", size="pop", color="continent",
hover_name="country", log_x=True, size_max=60)
fig.show()
This is used to generate an interactive scatter plot of GDP per capita against life expectancy for the year 2007, with marker size representing population, color indicating continent, and a logarithmic x-axis scale.
| Name | Age | Occupation | Location |
|---|---|---|---|
| Sumit | 30 | Teacher | Waterloo, Canada |
| Sourabh | 20 | Computer technician | Waterloo, Canada |
| Paras | 19 | Student | Waterloo, Canada |
| Lakshay | 26 | Data Analyst | Waterloo, Canada |